package com.cosina.test;

import java.nio.IntBuffer;

import javax.microedition.khronos.opengles.GL10;

public class Lession3Render extends BaseRender{
	 int one = 0x10000;
	
	 private IntBuffer colorBuffer = IntBuffer.wrap(new int[]{
			 one,0,0,one,
			 0,one,0,one,
			 0,0,one,one,
	 });
	 
	 
	 private IntBuffer triggerBuffer = IntBuffer.wrap(new int[]{
			0,one,0,
			-one,-one,0,
			one,-one,0,});
	 private IntBuffer quaterBuffer = IntBuffer.wrap(new int[]{
				one,one,0,
				-one,one,0,
				one,-one,0,
				-one,-one,0});
	@Override
	public void onDrawFrame(GL10 gl) {
		super.baseDrawFrame(gl);
		gl.glTranslatef(-1.5f, 0.0f, -6.0f);
		
		gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	
		gl.glColorPointer(4, GL10.GL_FIXED, 0, colorBuffer);
		gl.glVertexPointer(3, GL10.GL_FIXED, 0, triggerBuffer);
		
		
		gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
		
		 gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
		
		/* Set The Color To Blue One Time Only */
	    gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);

	    /* Disable vertex color array, use global color */
	    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
	    gl.glLoadIdentity();
	    gl.glTranslatef(1.5f, 0.0f, -6.0f);
	    
	    gl.glVertexPointer(3, GL10.GL_FIXED, 0, quaterBuffer);
	    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

	    /* Disable vertex array */
	    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	}
}